package vista;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class FrameSistema extends javax.swing.JFrame implements ActionListener {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private static final long serialVersionUID = 1L;
	private JLabel lblTituloSistema;
	private JButton btnTarifas;
	private JButton btnUsuario;
	private FrameUsuario frame;
	private TarifaFrame frameTablas;
	//COMANDOS PARA ACTION LISTENERS
	private static final String CMD_USUARIO="cmd_usuario";
	private static final String CMD_IMPUESTOS="cmd_impuestos";

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				FrameSistema inst = new FrameSistema();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public FrameSistema() {
		super();
		initGUI();
		//Crea el Frame Usuario
		this.frame= new FrameUsuario(); 
		this.frame.setVisible(false);
		
		//Crea el Frame AdministrarTabla
		this.frameTablas= TarifaFrame.getInstancia();
		this.frameTablas.setVisible(false);
	}
	
	private void initGUI() {
		try {
			GridLayout thisLayout = new GridLayout(4, 1);
			thisLayout.setHgap(5);
			thisLayout.setVgap(5);
			thisLayout.setColumns(1);
			thisLayout.setRows(4);
			getContentPane().setLayout(thisLayout);
			this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			this.setTitle("Sistema de Calculo de Impuesto Gas");
			{
				lblTituloSistema = new JLabel();
				getContentPane().add(lblTituloSistema);
				lblTituloSistema.setText("Sistema de calculo de impuesto de gas");
				lblTituloSistema.setFont(new java.awt.Font("Arial",1,12));
				lblTituloSistema.setHorizontalAlignment(SwingConstants.CENTER);
			}
			{
				btnTarifas = new JButton();
				getContentPane().add(btnTarifas);
				btnTarifas.setText("TARIFAS");
				btnTarifas.addActionListener(this);
				btnTarifas.setActionCommand(CMD_IMPUESTOS);
				btnTarifas.setPreferredSize(new java.awt.Dimension(247, 33));
			}
			{
				btnUsuario = new JButton();
				getContentPane().add(btnUsuario);
				btnUsuario.setText("USUARIO");
				btnUsuario.setActionCommand(CMD_USUARIO);
				btnUsuario.addActionListener(this);
				
				
			}
			pack();
			setSize(400, 300);
			this.setLocationRelativeTo(null);
			this.setResizable(false);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public void actionPerformed(ActionEvent arg0) {
		// Cuando se hace click en algunos de los botones
		//Elige la opcion "Usuario"
		if (CMD_USUARIO.equals(arg0.getActionCommand())){
			//Me abre el FrameUsuario
			 this.frame.setVisible(true); //Para mostrar la ventana
			// this.setVisible(false);//Oculta..VERRRRR!
	        }
		//Elige la opcion Impuestos
		else if (CMD_IMPUESTOS.equals(arg0.getActionCommand())){
			this.frameTablas.setVisible(true);
			
		}

	}		
}


